﻿
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>潜在客户管理</title>
    <#--引入的一些核心文件-->
    <#include "../common/link.ftl">
    <script>
        $(function () {
            //新增/编辑
            $('.btn-input').click(function () {
                //如果json不存在,不需要显示,要把表单里之前回显的内容清空
                $('#editForm select').val('-1');
                $('#editForm input').val('');
                var json = $(this).data("json");
                //获取编辑里定义的json
                //如果存在就是编辑,需要回显
                if(json){
                    $('input[name=id]').val(json.id);
                    $("select[name='customer.id']").val(json.customer.id);
                    $("select[name='course.id']").val(json.course.id);
                    $('input[name=money]').val(json.money);
                }
                $('#myModal').modal('show');
            })

            //异步请求保存
            $('.btn-submit').click(function () {
                $('#editForm').ajaxSubmit(handleMessage)
            })

        })
    </script>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <#include "../common/navbar.ftl">
    <#assign currentMenu="courseorder">
    <#include "../common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>潜在客户管理</h1>
        </section>
        <section class="content">
            <div class="box">
                <form class="form-inline" id="searchForm" action="/courseorder/list.do" method="post">
                    <input type="hidden" name="currentPage" id="currentPage" value="1">
                    <a href="#" class="btn btn-success btn-input" style="margin: 10px">
                        <span class="glyphicon glyphicon-plus"></span> 添加
                    </a>
                    <div class="form-group">
                        <label for="keyword">关键字:</label>
                        <input type="text" class="form-control" id="keyword" name="keyword" value="${qo.keyword!}" placeholder="请输入姓名/电话">
                    </div>
                     <#--通过销售课程查询下拉框-->
                    <div class="form-group">
                        <label for="courseId"> 销售课程:</label>
                        <select class="form-control" id="courseId" name="courseId">
                            <option value="-1">全部</option>
                                <#list subjects as s>
                                    <option value="${s.id}">${(s.title)!}</option>
                                </#list>
                        </select>
                    <#--查询时回显选中的销售员-->
                        <script>
                            $('#courseId').val(${qo.courseId});
                        </script>
                    </div>
                <#--按钮在表单内,不写type,默认是submit,可以提交,若是button没法提交-->
                    <button id="btn_query" class="btn btn-primary"><span class="glyphicon glyphicon-search"></span> 查询</button>
                </form>
                <!--编写内容-->
                <div class="box-body table-responsive no-padding ">
                    <table class="table table-hover table-bordered">
                        <tr>
                            <th>编号</th>
                            <th>客户姓名</th>
                            <th>销售课程</th>
                            <th>销售时间</th>
                            <th>销售金额</th>
                            <th>操作</th>
                        </tr>
                        <#list result.list as courseorder>
                            <tr>
                                <#--取值后面加个感叹号可以解决空指针问题,也可以感叹后加个默认值-->
                                <td>${courseorder_index+1}</td>
                                <td>${(courseorder.customer.name)!}</td>
                                <td>${(courseorder.course.title)!}</td>
                                <td>${(courseorder.inputTime?string('yyyy-MM-dd'))!}</td>
                                <td>${(courseorder.money)!}</td>
                                <td>
                                    <#--data-json后面要用单引号,不然json字符串过来拼接会有问题-->
                                    <#--编辑的时候需要将update的sql中不用修改的参数删掉,不然全部默认为空-->
                                    <a href="#" class="btn btn-info btn-xs btn-input" data-json='${courseorder.json!}'>
                                        <span class="glyphicon glyphicon-pencil"></span> 编辑
                                    </a>
                                </td>
                            </tr>
                        </#list>
                    </table>
                    <!--分页-->
                    <#include "../common/page.ftl">
                </div>
            </div>
        </section>
    </div>
        <#--引入主页面的底部(一些公司的信息)-->
    <#include "../common/footer.ftl">
</div>

<#--销售课程编辑模态框-->
<div class="modal fade" id="myModal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title inputTitle">课程编辑</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/courseorder/saveOrUpdate.do" method="post" id="editForm">
                    <input type="hidden"   name="id">
                    <div class="form-group" >
                        <label  class="col-sm-4 control-label">选择客户：</label>
                        <div class="col-sm-6">
                        <select class="form-control" name="customer.id">
                            <option value="-1">全部</option>
                                <#list customers as c>
                                    <option value="${c.id}">${c.name}</option>
                                </#list>
                        </select>
                        </div>
                    </div>
                    <div class="form-group" >
                        <label  class="col-sm-4 control-label">选择课程：</label>
                        <div class="col-sm-6">
                        <select class="form-control" name="course.id">
                            <option value="-1">全部</option>
                                <#list subjects as s>
                                    <option value="${s.id}">${s.title}</option>
                                </#list>
                        </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label  class="col-sm-4 control-label">课程价格：</label>
                        <div class="col-sm-6">
                            <input type="number" class="form-control" name="money"
                                   placeholder="请输入金额"/>
                        </div>
                    </div>
                </form>
                <div class="modal-footer">
                    <button type="butten" class="btn btn-primary btn-submit" >保存</button>
                    <button type="button" class="btn btn-default" data-dismiss="modal" >取消</button>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>
